//1.引入Vue
import Vue from "vue";

//2.引入VueRouter
import VueRouter from "vue-router";

//引入组件
import Login from "../pages/Login/login.vue"
import Home from "../pages/Home/home.vue"
import News from "../pages/Home/News"
import Music from "../pages/Home/Music"
import Games from "../pages/Home/Games"

//3.使用插件
Vue.use(VueRouter);

//4.创建路由器对象
export default new VueRouter({
    //在路由器对象中配置路由表
    routes: [
        {
            path: "/login",
            component: Login,
            name: "login"
        },
        {
            path: "/home",
            component: Home,
            children: [
                //在动态的params参数中,如果有可选的,请放在最后,并且添加一个?结尾
                {
                    path: "music/:id/:time?",
                    component: Music,
                    name: "music",
                    
                },
                {
                    path: "news",
                    component: News,
                    name: "news"
                },
                {
                    path: "games",
                    component: Games,
                    name: "games"
                },

                //重定向访问Home的默认子组件
                {
                    path: "/",
                    redirect: "/home/news"
                },
            ]
        },

        //重定向进页面直接跳转到Home组件
        {
            path: "/",
            redirect: "/home"
        }
    ]
})